Skip to content

[6.x] Make actions available in a collection tree view#14331

Open
Devsome wants to merge 6 commits intostatamic:6.xfrom
Devsome:6.x
Open

[6.x] Make actions available in a collection tree view#14331
Devsome wants to merge 6 commits intostatamic:6.xfrom
Devsome:6.x

Conversation

@Devsome
Copy link
Copy Markdown

@Devsome Devsome commented Mar 24, 2026

Hello everyone,

First of all, thank you for Statamic 6. After someone on Discord pointed me to Issue 575 and I saw the other pull requests 4070 & 4439, I decided to give it a try and follow the contribution guidelines.

Procedure:

  • Created a new blank project
  • Forked Statamic 6 and linked it locally in composer.json
  • Ran npm ci && npm run build in the statamic/cms project
  • Ran ddev artisan vendor:publish --tag=statamic-cp --force && ddev yarn build && ddev artisan optimize:clear
  • Created a custom action ddev artisan statamic:make:action

If I've forgotten anything or something is missing, please let me know. Even if it isn't accepted, as stated in the Contribution Guidelines, it might still be helpful to others who need it.

This is what my custom action looks like

<?php

namespace App\Actions;

use Illuminate\Support\Facades\Log;
use Statamic\Actions\Action;

class CustomActionInTreeView extends Action
{
    protected $icon = 'add-item';
    protected $confirm = false;

    /**
     * The run method
     *
     * @return mixed
     */
    public function run($items, $values)
    {
        Log::info('Custom Action in Tree View executed', [
            'items' => $items,
            'values' => $values,
        ]);
    }

    public static function title(): string
    {
        return 'Custom Action in Tree View';
    }

    public function visibleTo($item): bool
    {
        $view = $this->context['view'] ?? 'list';
        return $view === 'tree';
    }
}

How it looks like in the TreeView:
image

How it looks like in the ListView:
image

@Devsome Devsome changed the title Make actions available in a collection tree view [6.x] Make actions available in a collection tree view Mar 24, 2026
Copy link
Copy Markdown
Member

@jasonvarga jasonvarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good, thanks!

However we are moving away from sending all the actions down the wire initially. It really bloats the responses.

We have a mechanism to lazily load the actions when you hover over the dropdown. You should rework this PR to allow for that.

See RowActions.vue which is used in the Listing component.

https://github.com/statamic/cms/blob/6.x/resources/js/components/ui/Listing/RowActions.vue

In fact you might actually be able to use the RowActions component itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants